<?php $this->load->view('admin_home/_header') ?>
<?php $this->load->view('message') ?>

<script tyep="text/javascript">
  	$().ready(function(){
    	$("#test_point_li").addClass("active"); 

	    $("#test_point_add").validate({
						rules:{
							content:"required"
						},
					});
		$('.selectpicker').selectpicker();   
  	});

	function check_button_click()
  	{
  		var id=$(".selectpicker").val();
  		if(id!='0')
  			location.href="<?php echo site_url('admin_test_point/check').'/'?>"+id;
  	}

  	function edit_button_click()
  	{
  		var id=$(".selectpicker").val();
  		if(id!='0')
  			location.href="<?php echo site_url('admin_test_point/edit').'/'?>"+id;
  	}

  	function delete_button_click()
  	{
  		var id=$(".selectpicker").val();
  		if(id!='0')
  			if(confirm("删除后不可恢复，确定吗？"))
  				location.href="<?php echo site_url('admin_test_point/delete').'/'?>"+id;
  	}

  	function delete_item(id)
  	{
  		if(confirm("删除后不可恢复，确定吗？"))
  			location.href="<?php echo site_url('admin_test_point/delete').'/'?>"+id;
  	}
</script>

<div class="container">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">查询</h3>
		</div>
		<div class="panel-body">
			<div class="col-md-9">
				<select class="selectpicker form-control" id="test_points_select" data-live-search="true">
					<option value="0">点击输入查询的考点</option>
					<?php foreach ($test_points as $item ): ?>
						<option value="<?=$item['id']?>">
							<?=$item['content']?>
						</option>
					<?php endforeach ?>
				</select>
			</div>
			<div class="col-md-1">
				<button onclick="check_button_click()" class="btn btn-primary">查看</button>
			</div>
			<div class="col-md-1">
				<a onclick="edit_button_click()" class="btn btn-primary">编辑</a>
			</div>
			<div class="col-md-1">
				<a onclick="delete_button_click()" class="btn btn-primary">删除</a>
			</div>
		</div>
	</div>
</div>
<div class="container">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">当前的考点</h3>
		</div>
		<div class="panel-body">
			<div id="table">
				<table class="table table-striped table-hover ">
					<thead>
						<tr>
							<th>序号</th>
							<th>内容</th>
							<th>操作</th>
							<th></th>
							<th>
								<a href="<?php echo site_url('admin_test_point/add')?>" class="btn btn-primary ">添加</a>
							</th>
							
						</tr>
					</thead>
					<tbody>
						<?php $index=1; ?>
						<?php foreach ($test_points as $item ): ?>
						<tr>
							<td>
								<?php echo $index++?></td>
							<td>
								<?php echo mb_strlen($item['content']) <=25 ? $item['content'] : mb_substr($item['content'], 0,25).'......' ?></td>
							<td>
								<a href="<?php echo site_url('admin_test_point/check').'/'.$item['id']?>">查看</a>
							</td>
							<td>
								<a href="<?php echo site_url('admin_test_point/edit').'/'.$item['id']?>">编辑</a>
							</td>
							<td>
								<a onclick="delete_item(<?=$item['id']?>)" href="#">删除</a>
							</td>
						</tr>
						<?php endforeach; ?></tbody>
				</table>
			</div>
		</div>
	</div>
</div>

<?php $this->load->view('admin_home/_footer')?>